<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">

<head>
  <!-- Required meta tags -->
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
  <title>Purple Admin</title>
  <!-- plugins:css -->
  <link rel="stylesheet" href="vendors/iconfonts/mdi/css/materialdesignicons.min.css"/>
  <link rel="stylesheet" href="vendors/css/vendor.bundle.base.css"/>
  <!-- endinject -->
  <!-- inject:css -->
  <link rel="stylesheet" href="css/style.css"/>
  <!-- endinject -->
  <link rel="shortcut icon" href="images/favicon.png" />

</head>

<body>
 <div class="col-12 grid-margin stretch-card">
              <div class="card">
                <div class="card-body">
                  <h4 class="card-title">首页/设置/平台信息</h4>
                  <p class="card-description">
                    平台信息设置
                  </p>
                  <form id="fileForm" class="forms-sample"   enctype="multipart/form-data">
                    <div class="form-group">
                        <label for="exampleInputName1"><span class="s">*</span> 平台名称：</label>
                      <input name="platform_name" type="text" class="form-control" id="exampleInputName1" required="required" placeholder="平台简称，建议不超过4个字"/>
                    </div>
                    <div class="form-group">
                      <label for="exampleInputEmail3"><span class="s">*</span> 平台标题：</label>
                      <input name="platform_title" type="text" class="form-control" id="exampleInputEmail3" required="required" placeholder="平台完整名称"/>
                    </div>
                    <div class="form-group">
                      <label for="exampleInputPassword4">平台描述：</label>
                      <input name="platform_desc" type="text" class="form-control" id="exampleInputPassword4" placeholder=""/>
                    </div>
                      <div class="form-group">
                          <label for="exampleInputEmail3"><span class="s">*</span> 关键词：</label>
                          <input name="keyword" type="text" class="form-control" id="exampleInputEmail" required="required" placeholder=""/>
                      </div>
                    <div class="form-group">
                      <label><span class="s">*</span> 平台LOGO：</label>
                      <input id="file1" type="file" name="file1" required="required" class="file-upload-default" accept=".jpg,.png"/>
                      <div class="input-group col-xs-12">
                        <input type="text" class="form-control file-upload-info" disabled="" placeholder="只能上传jpg/png格式文件，文件不能超过10MB" />
                        <span class="input-group-append">
                          <button class="file-upload-browse btn btn-gradient-primary" type="button">选择上传文件</button>
                        </span>
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="exampleInputCity1"><span class="s">*</span> 客服热线：</label>
                      <input name="phone" type="text" class="form-control" id="exampleInputCity1" required="required" placeholder="" onchange="upperCase()"/>
                    </div>
					<div class="form-group">
                      <label for="exampleInputCity1"><span class="s">*</span> 客服邮箱：</label>
                      <input name="email" type="email" class="form-control" id="exampleInputCity2" required="required" placeholder="" onchange="emailCase()"/>
                    </div>
					<div class="form-group">
                      <label for="exampleInputCity1"><span class="s">*</span> 微信公众号名称：</label>
                      <input name="wechat_name" type="text" class="form-control" id="exampleInputCity3"  required="required" placeholder=""/>
                    </div>
					   <div class="form-group">
                      <label><span class="s">*</span> 公众号二维码：</label>
                      <input type="file" id="file2" name="file2" required="required" class="file-upload-default" accept=".jpg,.png"/>
                      <div class="input-group col-xs-12">
                        <input name="file2" type="text" class="form-control file-upload-info" disabled="" placeholder="只能上传jpg/png格式文件，文件不能超过10MB"/>
                        <span class="input-group-append">
                          <button class="file-upload-browse btn btn-gradient-primary" type="button">选择上传文件</button>
                        </span>
                      </div>
                    </div>
                      <label><span class="s">*</span> 用户协议：</label>
					<div id="editor">
                        <a name="user_agreement" id="user" th:text="${agreement}"></a>
                     </div>
                    <button type="submit" class="btn btn-gradient-primary mr-2" onclick="update()">Submit</button>
                  </form>
                </div>
              </div>
            </div>

 <!-- 注意， 只需要引用 JS，无需引用任何 CSS ！！！-->
 <script type="text/javascript" src="js/wangEditor.min.js"></script>
 <script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
 <script type="text/javascript">

     var E = window.wangEditor
     var editor = new E('#editor')
     // 或者 var editor = new E( document.getElementById('editor') )
     editor.create()

     function upperCase() {
         var phone = document.getElementById('exampleInputCity1').value;
         var re = /^0\d{2,3}-?\d{7,8}$/;
         if(re.test(phone)){
            alert("正确");


         }else{
             alert("错误");

         }
     }
     function emailCase() {
         var email = document.getElementById('exampleInputCity2').value;
         var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/
         if(re.test(email)){
           alert("正确");

         }else{
            alert("错误");

         }
     }
     
     function update() {
         var name = $("#exampleInputName1").val();
         var title = $("#exampleInputEmail3").val();
         var describe = $("#exampleInputPassword4").val();
         var keyword = $("#exampleInputEmail").val();
         var phone = $("#exampleInputCity1").val();
         var mailbox = $("#exampleInputCity2").val();
         var weChat = $("#exampleInputCity3").val();
         // var file1 = $("#file1").val();
         // var file2 = $("#file2").val();
         var user = $("#user").text();
        // alert("修改成功！");
         /*<![CDATA[*/
         /*]]>*/
         var fm = new FormData($( "#fileForm" )[0]);
         fm.set("user_agreement",user);
         //进行Ajax请求
         $.ajax({
             //几个参数需要注意一下
             type: "POST",//方法类型
             dataType: "json",//预期服务器返回的数据类型,可以不设置
             url: "/huxuan/put" ,//url
             data: fm,
             async: false,
             cache: false,
            contentType: false, //禁止设置请求类型
             processData: false, //禁止jquery对DAta数据的处理,默认会处理
             success: function () {

             },
             error : function() {

             }
         });



     }
 </script>
  <!-- container-scroller -->
  <!-- plugins:js -->
  <script src="vendors/js/vendor.bundle.base.js"></script>
  <script src="vendors/js/vendor.bundle.addons.js"></script>
  <!-- endinject -->
  <!-- inject:js -->
  <script src="js/off-canvas.js"></script>
  <script src="js/misc.js"></script>
  <!-- endinject -->
  <!-- Custom js for this page-->
  <script src="js/file-upload.js"></script>
  <!-- End custom js for this page-->
</body>

</html>
